<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>喜餐订货管理系统</title>
    <link rel="stylesheet" href="plugins/layui/css/layui.css" media="all" />
	<link rel="icon" href="images/faviconL.ico" type="image/x-icon" />
    <style>
        .login_bg{
            position: absolute;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background: url('./images/icon_bg@2x.png') no-repeat;
            background-size: 100% 100%;
        }
        .Box {
            width: 410px;
            height: 375px;
            position: absolute;
            top: 50%;
            left: 50%;
            margin-left: -205px;
            margin-top: -187.5px;
            border-radius: 5px;
            background: #fff;
        }
        .loginBox{
            padding: 20px 30px;
            box-sizing: border-box;
        }
        .logint{
            text-align: center;
            height: 90px;
            line-height: 80px;
            font-weight: 500;
            font-size: 26px;
            font-family:Source Han Sans CN;
        }
        .layui-form-item{
            position: relative;
            margin-bottom: 30px;
        }
        .title_txt {
            width: 60px;
            height: 30px;
            padding: 9px 0;
            text-align: left;
        }
        .layui-form-item:last-child{
            margin-bottom: 0;
            margin-top: 30px;
        }
        .layui-input-block {
            margin-left: 60px;
        }
        @media screen and (max-width: 450px){
            .logint{
                height: 60px;
                line-height: 50px;
                font-size: 20px;
            }
            .Box {
                width: 280px;
                height: 232px;
                position: absolute;
                top: 50%;
                left: 50%;
                margin-left: -140px;
                margin-top: -116px;
            }
            .loginBox{
                background: #fff;
                padding: 10px 20px;
                box-sizing: border-box;
                border-radius: 5px;
            }
            .layui-form-item{
                margin-bottom: 15px;
            }
            .layui-form-item:last-child{
                margin-top: 20px;
            }

        }
    </style>
</head>
<body>
   <div class="login_bg">
    <div class="Box">
        <div class="loginBox">
            <div class="logint">喜餐订货平台登录</div>
            <div id="loginForm" class="layui-form" >
                <form class="layui-form" id="form" lay-filter="example">
                    <div class="layui-form-item">
                        <label class="layui-form-label title_txt">帐号：</label>
                        <div class="layui-input-block">
                            <input class="layui-input" type="text" name="account" placeholder="请输入登录用户名" maxlength="20" autocomplete="off"/>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label title_txt">密码：</label>
                        <div class="layui-input-block">
                            <input class="layui-input" type="password" name="password" placeholder="请输入登录密码" maxlength="20" autocomplete="off"/>
                        </div>
                    </div>
                    <!-- <div>
                        <input type="checkbox" name="remeber" title="记住密码" lay-skin="primary"> 
                    </div> -->
                </form>
                <div class="layui-form-item">
                    <button class="layui-btn layui-btn-fluid" type="button" id="btn_Login" lay-submit lay-filter="login">登录</button>
                </div>
            </div>
        </div>
    </div>
   </div> 
</body>
<script type="text/javascript" src="plugins/layui/layui.js"></script>
<script type="text/javascript" src="js/jquery.min.js"></script>
<script>
    
    layui.config({
        base: 'plugins/layui/modules/',
    }).use(['http', 'form'], function() {
        var http = layui.http,
            form = layui.form;

        if (top.location != location) {
            top.location.href = location.href;
        }

        localStorage.setItem('xi-can-management-userInfo','')
        // localStorage.setItem('xi-can-management-login','')
        localStorage.setItem('xi-can-management-authentication','')
        localStorage.setItem('xi-can-management-userInfo','')
        // var loginInfo = localStorage.getItem('xi-can-management-login')
        // if(loginInfo){
        //     loginInfo = JSON.parse(loginInfo)
        //     form.val('example', {
        //         "account": loginInfo.account
        //         ,"password": loginInfo.password
        //     });
        // }

        //回车
        $(document).keydown(function(event) {
            if (event.keyCode == 13) {
                $("#btn_Login").click();
            }
        });

        //提交
        form.on('submit(login)', function(data) {
            var field = data.field;
            var account = field.account
            var password = field.password
            var remeber = field.remeber
            // console.log(remeber)
            if ($.trim(account) == "") {
                layer.msg('用户名不能为空')
                return
            }
            if ($.trim(password) == "") {
                layer.msg('密码不能为空')
                return
            }
            http.post('admin/admin/login',{
                account: account,
                password: password
            },function(res){
                if(res.code == 200){
                    layer.msg('登录成功')
                    // if(remeber){
                    //     var info = {
                    //         account: account,
                    //         password: password
                    //     }
                    //     localStorage.setItem('xi-can-management-login',JSON.stringify(info))
                    // }
                    localStorage.setItem('xi-can-management-userInfo',JSON.stringify(res.data))
                    setTimeout(function(){
                        window.location.href = "index.html";
                    },500)
                }else{
                    layer.msg(res.msg)
                }
            })
            
        })
    })

</script>
</html>